﻿Public Class ConfirmationSent
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If String.IsNullOrEmpty(Request.QueryString("UserId")) Then
            lbl_VerificationMessageLabel.Text = "No user id was specified....."
        Else
            Dim userId As Guid
            Try
                userId = New Guid(Request.QueryString("UserId"))
            Catch ex As Exception
                lbl_VerificationMessageLabel.Text = "The user id specified in not in the proper format"
                Return
            End Try
            Dim user As MembershipUser = Membership.GetUser(userId)
            If IsDBNull(user) Then
                lbl_VerificationMessageLabel.Text = "No corresponding user account could be found..."
            ElseIf user.IsApproved Then
                lbl_VerificationMessageLabel.Text = "The specified user account was previously activated..."
            Else
                user.IsApproved = True
                Membership.UpdateUser(user)
                Dim baseUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath
                lbl_VerificationMessageLabel.Text = "Your account has been activated. Please " & String.Format("<A HREF= ""{0}"">{2}</A>", baseUrl & "Login.aspx", "click here") & "to login."
            End If
        End If
    End Sub

End Class